home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15128 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  42 lines

  1. Newsgroups: comp.lang.c++
  2. Path: undergrad.math.uwaterloo.ca!sckettle
  3. From: sckettle@undergrad.math.uwaterloo.ca (Steve Kettle)
  4. Subject: Re: How to initialize array of objects using non-void constructor?
  5. Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
  6. Message-ID: <DpAoG2.nCn@undergrad.math.uwaterloo.ca>
  7. Date: Wed, 3 Apr 1996 16:28:50 GMT
  8. References: <4jbuo5$mcb@newshost.lanl.gov> <315C8F65.78D5@aai.arco.com> <315F5E13.799D1B33@alcyone.com>
  9. Nntp-Posting-Host: noether.math.uwaterloo.ca
  10. Organization: University of Waterloo
  11.  
  12. In article <315F5E13.799D1B33@alcyone.com>,
  13. Erik Max Francis  <max@alcyone.com> wrote:
  14. >Brian Leach wrote:
  15. >
  16. >> Liang Lu wrote:
  17. >> >
  18. >> > Example:
  19. >> >
  20. >> > class Table {
  21. >> >         Table() ;
  22. >> >         Table(int n) ;
  23. >> > ..
  24. >> > } ; 
  25. >> >
  26. >> > Table object[10] ; // default constructor are used here
  27. >>
  28. >> Sorry Liang, it is not possible. The language does not allow for
  29. >> non-default
  30. >> constructors for arrays of objects.
  31. >
  32. >Nonsense; see Ellis & Stroustrup, 12.6.1.  Using non-default constructors for
  33. >initializing an array is much the same as one would expect (using the example
  34. >above):
  35. >
  36. >    Table object[3] = { object(1), object(1), object(2) };
  37. >
  38. >-- 
  39.  
  40. But you can't for an array on the heap.  
  41. -- 
  42.